<%@ page contentType="text/html;charset=utf-8"%>
<%@ page import="java.util.*"%>
<%
List<Map> lt = (List)request.getAttribute("list");
Map queryMap = (HashMap)request.getAttribute("queryMap");
List<Map> gameType = (List<Map>) request.getAttribute("gameType");
List<Map> gamePlatForm = (List<Map>) request.getAttribute("gamePlatForm");

%>
<div class="content-box">	
<script type="text/javascript" src="/resources/scripts/JTimer.js"></script>
<script>
//查询
function toSearch(){
	//计算游戏平台选项
	var gamePlatFormIds=document.getElementsByName("game_platform_id_obj");
	var gamePlatFormId="";
	if(gamePlatFormIds.length>0){
		for(var t=0;t<gamePlatFormIds.length;t++){
			if(gamePlatFormIds[t].checked==true){
				gamePlatFormId+=(gamePlatFormIds[t].value+",");
			}
		}
		gamePlatFormId=gamePlatFormId.substring(0,gamePlatFormId.length-1);
	}
	document.getElementsByName("game_platform_id")[0].value=gamePlatFormId;
	
	//提交表单
	var searchForm = document.getElementsByName("searchForm")[0];
	searchForm.action="gameManage.do?pm=gotoGameList";
	searchForm.submit();
}

//修改
function toModify(obj){
var modifyId=$(obj).parent().parent().find("input[type=checkbox]").attr("id");
	var searchForm = document.getElementsByName("searchForm")[0];
	searchForm.action="gameManage.do?pm=gotoGameModify&id="+modifyId;
	searchForm.submit();
}
//删除
function toDelete(obj){
var modifyId=$(obj).parent().parent().find("input[type=checkbox]").attr("id");
	var confirmFlag= window.confirm("确认删除此记录？");
	if(confirmFlag){
		//location.href="gameManage.do?pm=gameDelete&id="+modifyId;
		var searchForm = document.getElementsByName("searchForm")[0];
		searchForm.action="gameManage.do?pm=gameDelete&id="+modifyId;
		searchForm.submit();
		}
}
//删除所有标记的id
function deleteAll(){
	var deleteIds="";
	var deleteRecordcount=0;
	$(" #jdstudio_content_tr > [mvflagBycheck='true'] ").find(" input[type='checkbox'] ").each(function(){
		if($(this).attr("checked")){
			deleteIds+=$(this).attr('id')+",";
			deleteRecordcount++;
		}
	});
	if(deleteIds!=""){
		deleteIds=deleteIds.substring(0,deleteIds.length-1);
		var confirmFlag= window.confirm("确认删除"+deleteRecordcount+"笔记录？");
		if(confirmFlag){
		location.href="gameManage.do?pm=gameDelete&id="+deleteIds;
		}
	}else{
		alert("请选择记录！");
	}
}


</script>		
<script type="text/javascript">
/*******************分页查询模块JS*******************/
$(document).ready(function(){
var currentPage= $("#DispCurrentPage").html();
var maxPages= $("#DispMaxPages").html();
function toPageSearch(control){
	if(control=='first'){
		$("#CurrentPage").val("1");
	}else if(control=='prev'){
		$("#CurrentPage").val(parseInt(currentPage)-1);
	}else if(control=='next'){
		$("#CurrentPage").val(parseInt(currentPage)+1);
	}else if(control=='last'){
		$("#CurrentPage").val(maxPages);
	}else if(control=='goto'){
		if($("#Page_Goto").val()==''){
			alert("跳转页数为空！");
		}else{
			if(parseInt($("#Page_Goto").val())<1)
				$("#CurrentPage").val("1");
			else if(parseInt($("#Page_Goto").val())>parseInt(maxPages))
				$("#CurrentPage").val(maxPages);
			else 
				$("#CurrentPage").val($("#Page_Goto").val());
		}
	}
	var searchForm = document.getElementsByName("searchForm")[0];
	searchForm.action="gameManage.do?pm=gotoGameList";
	searchForm.submit();
}
$("#Page_First").click(function(){toPageSearch("first")});
$("#Page_Prev").click(function(){toPageSearch("prev")});
$("#Page_Next").click(function(){toPageSearch("next")});
$("#Page_Last").click(function(){toPageSearch("last")});
$("#Page_Goto_Btn").click(function(){toPageSearch("goto")});
if(currentPage=="1"){
	$("#Page_First").unbind("click").hide();
	$("#Page_Prev").unbind("click").hide();
}
if(currentPage==maxPages){
	$("#Page_Next").unbind("click").hide();
	$("#Page_Last").unbind("click").hide();
}
$(".pagination").show();

//注入勾选菜单
var gamePlatFormIds='${queryMap.game_platform_id}';
$("input[name='game_platform_id_obj']").each(function(){
	if(gamePlatFormIds.indexOf($(this).attr("value"))!=-1){
		$(this).attr("checked","true");
	}
})


})
/*******************分页查询模块JS_end*******************/
</script>		
				<div class="content-box-header">
					<h3>图鉴搜索条件</h3>
					<div class="clear"></div>
				</div> 
                <div class="content-box-content">
                <form name="searchForm" method="post">
               	   <table>
               	   	<thead>
               	   		   <!-- 分页条件START -->
									<input name="CurrentPage"  id="CurrentPage" style="display: none" value="" />
						   <!-- 分页条件END -->
						   <tr style="padding: 4px">
		                   	   <td style="width:100px;text-align:right">游戏名称:&nbsp;</td>
		                       <td style="width:150px"><input type="text" name="simplified_chinese_name" value="${queryMap.simplified_chinese_name}" size="24" maxlength="24"></td>
		                       <td style="width:100px;text-align:right">发行日期:&nbsp;</td>
		                       <td style="width:150px"><input type="text" name="publish_date" value="${queryMap.publish_date}" size="24" onclick="JTC.setday(this)" readonly maxlength="24"> </td>
		                   </tr>
		                   <tr>
		                   		<td colspan="4">&nbsp;</td>
		                   </tr>
		                   <tr style="padding: 4px">
		                   	   <td style="width:100px;text-align:right">游戏类型:&nbsp;</td>
		                       <td style="width:150px">
		                        <select name="game_type_id">
		                        	<option value="">所有</option>
									<%
										if(gameType.size()>0){
										for (int t = 0; t < gameType.size(); t++) {
									%>
									<option <%= queryMap!=null?(queryMap.get("game_type_id")!=null?(queryMap.get("game_type_id").equals(gameType.get(t).get("game_type_id"))?"selected":""):""):""  %> value="<%=gameType.get(t).get("game_type_id")%>"><%=gameType.get(t).get("game_type_name")%>(<%=gameType.get(t).get("game_type")%>)</option>
									<%
										}}
									%>
								</select>
		                       </td>
		                   	   <td style="width:100px;text-align:right">厂商:&nbsp;</td>
		                       <td style="width:150px"><input type="text" name="game_publish_company" value="${queryMap.game_publish_company}"  size="24" maxlength="24"></td>
		                   </tr>
		                    <tr>
		                   		<td colspan="4">&nbsp;</td>
		                   </tr>
		                   <tr style="padding: 4px">
		                   	   <td style="width:100px;text-align:right">游戏平台(or):&nbsp;</td>
		                       <td style="width:150px" colspan="3">
		                       	<%
								for (int t = 0; t < gamePlatForm.size(); t++) {
								%>
								<input type="checkbox" name="game_platform_id_obj" value="<%=gamePlatForm.get(t).get("game_platform_id")%>"><%=gamePlatForm.get(t).get("game_platform_name")%>&nbsp;&nbsp;
								<%
									}
								%>
								</td>
								<input type="hidden" value="${queryMap.game_platform_id}" name="game_platform_id"/>
		                   </tr>
		                   <tr>
		                  	   <td colspan="3"></td>
		                  	   <td style="text-align: right"><input style="border:solid 1px #000;width:160px;cursor:pointer;height:40px;margin-top:8px" onmousemove=(this.style.background='#57a000') onmouseout=(this.style.background='#FFF') onclick="toSearch()" type="button" value="查询"/></td>
		                   </tr>
		             </thead>
                   </table>
                   </form>
                </div>
</div>
<div class="content-box"><!-- Start Content Box -->
				<div class="content-box-header">
					<h3>图鉴列表</h3>
					<div class="clear"></div>
				</div> <!-- End .content-box-header -->
				<div class="clear"></div>
				<div style="text-align: right;padding: 5px"><input style="border:solid 1px #CCC;width:100px" type="button" onclick="location.href='gameManage.do?pm=gotoGameAdd'" onmousemove=(this.style.background='#57a000') onmouseout=(this.style.background='#FFF') value="新增"/>&nbsp;&nbsp;<input style="border:solid 1px #CCC;width:100px" type="button" onmousemove=(this.style.background='#57a000') onmouseout=(this.style.background='#FFF') value="删除" onclick="deleteAll()"/></div>
				<div class="clear"></div>
				<div>
					<div id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
					  <table>
							<thead>
								<tr class="content-box-head" >
								   <th style="text-align:center;width: 2px"><input class="check-all" type="checkbox" /></th>
								   <th style="width:20%">游戏名称</th>
								   <th style="width:20%">英文名称</th>
								   <th style="width:10%">游戏类型</th>
								   <th style="width:10%">发行厂商</th>
								   <th>发行日期</th>
								   <th>点击数</th>
								   <th>置顶</th>
								   <th>有效</th>
								   <th style="width: 4px">操作</th>
								</tr>
							</thead>
							<tbody id="jdstudio_content_tr">
								<%
								if(lt.size()>0){
									for(int t=0;t<lt.size();t++){
								%>
								<tr mvflagBycheck="true">
									<td style="text-align:center;"><input type="checkbox" id="<%=lt.get(t).get("game_id").toString() %>" /></td>
									<td><%=lt.get(t).get("simplified_chinese_name")!=null?lt.get(t).get("simplified_chinese_name").toString():"" %></td>
									<td><%=lt.get(t).get("english_name")!=null?lt.get(t).get("english_name").toString():""%></td>
									<td><%=lt.get(t).get("game_type_name")!=null?lt.get(t).get("game_type_name").toString():"" %></td>
									<td><%=lt.get(t).get("game_publish_company")!=null?lt.get(t).get("game_publish_company").toString():""%></td>
                                    <td><%=lt.get(t).get("publish_date")!=null?lt.get(t).get("publish_date").toString():""%></td>
                                    <td><%=lt.get(t).get("game_click")!=null?lt.get(t).get("game_click").toString():"" %></td>
                                    <td><%=(lt.get(t).get("game_position_top")!=null?lt.get(t).get("game_position_top").toString():"").equals("1")?"是":"否" %></td>
                                    <td><%=(lt.get(t).get("game_enable")!=null?lt.get(t).get("game_enable").toString():"") .equals("1")?"是":"否" %></td>
									<td>
										<!-- Icons -->
										 <a onclick="toModify(this);" style="cursor:pointer" title="编辑"><img src="/resources/images/icons/pencil.png" alt="编辑" /></a>
										 <a onclick="toDelete(this);" style="cursor:pointer" title="删除"><img src="/resources/images/icons/cross.png" alt="删除"  /></a> 
									</td>
								</tr>
								<%}}else{ %>
								<%} %>
							</tbody>
							<tfoot style="width:auto">
								<!-- 分页查询模块HTML -->
								<table>
										<div class="pagination" style="display:none">
											<a href="#">当前第<span id="DispCurrentPage">${queryMap.CurrentPage}</span>页&nbsp;共计<span id="DispMaxPages">${queryMap.MaxPages}</span>页&nbsp;总计${queryMap.MaxRecords}笔数据</a>
											<a id="Page_First" title="第一页" style="cursor:pointer;">&laquo; 第一页</a><a id="Page_Prev" title="上一页" style="cursor:pointer;">&laquo; 上一页</a>
											<a id="Page_Next" title="下一页" style="cursor:pointer;">下一页 &raquo;</a><a id="Page_Last" title="最后一页" style="cursor:pointer;">最后一页 &raquo;</a>
											<input id="Page_Goto" name="page" value="" size="4" maxlength="4" type="text" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" /> <a id="Page_Goto_Btn" style="cursor:pointer;">跳转</a>
										</div>
										<div class="clear"></div>
								</table>
								<!-- 分页查询模块HTML END-->
							</tfoot>
						</table>
						
					</div> <!-- End #tab1 -->
					
					
					
				</div> <!-- End .content-box-content -->
				
</div>